<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Car {
        constructor(name, color) {
          this.name = name
          this.color = color
          this.price = 0
        }
        //acitve_price 用get的设置的属性 唯一的属性 设置只读属性
        get acitve_price() {
          return this.price
        }
        //s_price 用来设置 this.price 从而改变active_price
        set s_price(val) {
          if (val > 170) {
            this.price = val * 0.8
          }
        }
      }
      var benchi = new Car('奔驰', '红色')
      console.log(benchi.acitve_price)
      benchi.s_price = 180
      console.log(benchi.acitve_price)
      benchi.acitve_price = 190
      console.log(benchi.acitve_price)
    </script>
  </body>
</html>
